<{include file="public/header.html"}>
<script type='text/javascript'>var type = "hot";</script>
<!--问答 首页-->
<header class="title-fixed w100">
    <div class="title title-border-sm bj-white">
        <a href="/task.html" class="title-top title-left col-red iconfont">&#xe604;</a>
        <h1 class="text-center name">任务详情</h1>
    </div>
</header>
<div class="task-detail mt50">
    <div class="task-detail-head">
        <div class="top">
            <div class="head f-cb">
                <img src="<{$task['logo']}>" alt="<{$task['title']}>" class="logo fl">
                <div class="label-box fr">
                    <{foreach from=$task['task_tags'] item=val}>
                    <span><{$val}></span>
                    <{/foreach}>
                </div>
            </div>
            <div class="detail-desc f-cb">
                <div class="name-who fl">
                    <h5><{$task['title']}></h5>
                    <p>发布人：<{$task['username']}></p>
                </div>
                <{if $task['cate_id']==1}>
                <div class="earning fr">
                    <h5><{$task['profit_amount']}>元</h5>
                    <p>预期总收益</p>
                </div>
                <{/if}>
                <{if $task['cate_id']==2}>
                <div class="earning fr">
                    <h5><{$task['commission']}>元</h5>
                    <p>佣金</p>
                </div>
                <{/if}>
            </div>
            <{if $task['cate_id']==1}>
            <!--收益详情-->
            <div class="earn-detail" style="display: block;">
                <p>收益详情：</p>
                <div class="part-parent">
                    <div class="child">
                        <div class="part"><{$task['commission']}></div>
                        <div class="part">+</div>
                        <div class="part"><{$task['expected_money']}></div>
                        <div class="part">+</div>
                        <div class="part"><{$task['bonus']}></div>
                    </div>
                    <div class="child">
                        <div class="part">佣金</div>
                        <div class="part">&nbsp;</div>
                        <div class="part">理财收益</div>
                        <div class="part">&nbsp;</div>
                        <div class="part">红包</div>
                    </div>
                </div>
            </div>
            <{/if}>
        </div>
        <div class="pannel mt10">
            <h3>任务详情</h3>
            <div class="text">
                <p>任务期限：
                    <{if $status==5 && $left_time}>
                    <label class="red" id="left_time" data-time="<{$left_time}>">
                        <i id="day_show"></i><i id="hour_show"></i><i id="minute_show"></i><i id="second_show"></i>
                    </label>
                    <script>
                        var intDiff = parseInt($("#left_time").attr("data-time"));//倒计时总秒数量
                        function timer(intDiff) {
                            window.setInterval(function () {
                                var day = 0, hour = 0, minute = 0, second = 0;//时间默认值
                                if (intDiff > 0) {
                                    day = Math.floor(intDiff / (60 * 60 * 24));
                                    hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                                    minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                                    second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
                                }
                                if (minute <= 9) minute = '0' + minute;
                                if (second <= 9) second = '0' + second;

                                day > 0 ? $('#day_show').html(day + "天") : $('#day_show').html('');
                                hour > 0 ? $('#hour_show').html(hour + '小时') : $('#hour_show').html('');
                                $('#minute_show').html(minute + '分');
                                $('#second_show').html(second + '秒');

                                intDiff--;
                            }, 1000);
                        }
                        $(function () {
                            timer(intDiff);
                        });
                    </script>
                    <{else}>
                    <label class="red">
                        <i><{$dead_time}>小时</i>
                    </label>
                    <{/if}>
                </p>
                <{if $task['cate_id']==3}>
                <p>剩余额度：<{$task['max_over']}></p>
                <p>投资总金额：<{$task['investment_money_amount']}>元</p>
                <p>投资天数：<{$task['investment_day']}>天</p>
                <{else}>
                    <{if $task['cate_id']==4}>
                    <p>需求总数：<{$task['sub_num']}></p>
                    <{else}>
                    <p>剩余数量：<{$task['surplus']}></p>
                    <{/if}>
                    <{if $task['cate_id']==1}>
                    <p>投资金额：<{$task['investment_money']}>元</p>
                    <p>投资天数：<{$task['investment_day']}>天</p>
                    <{/if}>
                <{/if}>

            </div>
        </div>
        <div class="pannel">
            <h3>任务说明</h3>
            <div class="text">
                <{if $task['cate_id']==3}>
                    <p>预期总收益 </p>
                    <p>     = 佣金金额 + 利息收益 + 红包金额 </p>
                    <p>     = 投资金额*<{$task['commission_per']}>% + 投资金额*<{$task['interest_rate']}>% + <{$task['bonus']}></p>
                <{else}>
                    <p>预期总收益构成：</p>
                    <p>（佣金：<{$task['commission']}>元<{if
                        $task['cate_id']==1}> + 理财收益：<{$task['expected_money']}>元 +
                        红包：<{$task['bonus']}>元<{/if}>）</p>
                <{/if}>
                <p>弹溜溜任务流程：登录弹溜溜账号--领取弹溜溜任务并在规定时间内完成任务--完成后按要求提交任务--审核通过后溜溜币直接发放到弹溜溜账户--提现（绑定支付宝）1-2个工作日到账</p>
                <p><{$task['description']}></p>
            </div>
        </div>
        <div class="pannel">
            <h3>任务教程</h3>
            <div class="text">
                <p>验证条件：
                    <{if in_array(1,$task['validate'])}>姓名&nbsp;&nbsp;<{/if}>
                    <{if in_array(2,$task['validate'])}>身份证&nbsp;&nbsp;<{/if}>
                    <{if in_array(3,$task['validate'])}>手机号<{/if}></h3>
                </p>
                <{$task['content']}>
            </div>
        </div>
        <{if $task['img_list']}>
        <div class="pannel">
            <h3>截图示例</h3>
            <div class="text">
                <ul class="ht_ul" id="preview">
                    <{if $task['img_list']}>
                    <{foreach from=$task['img_list'] item=vimgval}>
                    <li style="float: left;width: 42%;margin: 5px;"><img src="<{$vimgval}>" width="200"></li>
                    <{/foreach}>
                    <div class="clear"></div>
                    <{/if}>
                </ul>
            </div>
        </div>
        <{/if}>
    </div>
    <div class="task-detail-foot">
        <{if $status==1}>

        <{elseif $status==2}>
        <div class="btn-receive">
            已结束
        </div>
        <{elseif $status==3}>
        <div class="btn-receive">
            已领完
        </div>
        <{elseif $status==4}>
        <div class="btn-receive" onclick="ajaxApply_type(<{$task['tid']}>,<{$task['cate_id']}>,<{$task['_invite']}>);">
            立即领取
        </div>
        <{elseif $status==5 && $left_time}>
        <div class="btn-receive" id="cancel_apply" style="background: #4b83ca;">取消任务</div>
        <{if $task['redirect_url']}>
        <div class="btn-receive" onclick="window.location.href=$(this).attr('data-href');"
             data-href="/task/task_redirect.html?tid=<{$task['tid']}>" target="_blank">去做任务
        </div>
        <div class="btn-receive" onclick="window.location.href=$(this).attr('data-href');"
             data-href="/task/info.html?type=1&tid=<{$task['tid']}>">提交验证
        </div>
        <{else}>
        <div class="btn-receive" onclick="window.location.href=$(this).attr('data-href');"
             data-href="/task/info.html?type=1&tid=<{$task['tid']}>">提交验证
        </div>
        <{/if}>
        <{elseif $status==6}>
        <div class="btn-receive" onclick="window.location.href=$(this).attr('data-href');"
             data-href="/task/info.html?type=2&tid=<{$task['tid']}>">修改验证
        </div>
        <div class="btn-receive" onclick="window.location.href='/account/taskrec.html'">查看</div>
        <{elseif $status==7 || $status==8}>
        <div class="btn-receive" onclick="window.location.href='/account/taskrec.html'">查看</div>
        <{/if}>
    </div>
</div>
<div class="public-field-bj publick-jq2" id="alert_mes">
    <div class="public-field-phone w100" id="alert_mes_cont" style="bottom: 5px;">
        <div class="plr15">
            <ul class="bj-white Creditinfo">
                <li style="font-size: 16px;color:black;">确认申请信息</li>
                <{if $task['_invite']==1}>
                <li><input type="text" style="line-height: 45px;font-size: 18px;text-align: center;width: 100%;"
                           name="invite_code" id="invite_code" placeholder="请输入邀请码"/></li>
                <{/if}>
                <{if $task['cate_id']==3}>
                <li><input type="number" style="line-height: 45px;font-size: 18px;text-align: center;width: 100%;"
                           name="investment_money" id="investment_money" value="" min="<{$task['min_over']}>"
                           max="<{$task['can_recive_money']}>"
                           placeholder="请输入投资金额（<{$task['min_over']}>-<{$task['can_recive_money']}>）"/></li>
                <{/if}>
            </ul>
            <button class="btn bj-white mt5" id="submit_invite" data-id=""
                    style="border-radius: 12px;width: 49%;color:#d70e0e">确认
            </button>
            <button class="btn bj-white mt5" id="cancel_bt" style="border-radius: 12px;width: 49%;">取消</button>
        </div>
    </div>
</div>
<div class="public-field-bj publick-jq2" id="alert_cancel">
    <div class="public-field-phone w100" id="alert_cancel_cont" style="bottom: 5px;">
        <div class="plr15">
            <ul class="bj-white">
                <li data-type="0">确认取消该任务？</li>
            </ul>
            <button class="btn bj-white mt5" id="delete-bind" data-id="<{$task['tid']}>"
                    style="border-radius: 12px;width: 49%;color:#d70e0e">确认
            </button>
            <button class="btn bj-white mt5 close-jq _close" style="border-radius: 12px;width: 49%;">取消</button>
        </div>
    </div>
</div>
<{include file="public/footer_login.html"}>
<style>
    .ht_ul {
        width: 100%;
        height: auto;
    }

    .ht_ul li {
        border: 1px solid #e5e5e5;
        width: auto;
        padding: 10px;
    }

</style>
<!--footer-->
<script type="text/javascript">

    //异步申请任务，也就是提交子任务
    function ajaxApply(tid, invite_code, investment_money) {
        var params = {};
        if (invite_code) {
            params.invite_code = invite_code;
        }
        if (investment_money) {
            params.investment_money = investment_money;
        }
        params.tid = tid;
        $.ajax({
            url: "/task/ajax_apply.html",
            async: true,
            type: "post",
            dataType: "json",
            data: params,
            success: function (res) {
                $.mvalidateTip(res.msg);
                setTimeout(function () {
                    location.href = res.link;
                }, 2000);
            }
        });
    }
    $("#cancel_bt").click(function () {
        $("#alert_mes").stop().fadeOut();
    });
    //异步申请任务，也就是提交子任务
    function ajaxApply_type(tid, cate_id, _invite) {
        if (is_login.uuid) {
            if (cate_id == 3 || _invite == 1) {
                var params = {};
                params.tid = tid;
                $("#alert_mes").stop().fadeIn();
                $("#submit_invite").on("click", function () {
                    var invite_code = $("#invite_code").val();
                    var investment_money = $("#investment_money").val();
                    var min = $("#investment_money").attr('min');
                    var max = $("#investment_money").attr('max');
                    if (_invite == 1 && invite_code.length == 0) {
                        $.mvalidateTip("请输入邀请码");
                        return;
                    }
                    if (cate_id == 3 && investment_money.length == 0) {
                        $.mvalidateTip("请输入投资金额");
                        return;
                    } else if (Number(investment_money) < min || Number(investment_money) > max) {
                        $.mvalidateTip("投资金额必须在" + min + "-" + max + "之间");
                        return;
                    }
                    ajaxApply(tid, invite_code, investment_money);
                    $("#alert_mes").stop().fadeOut();
                });
            } else {
                ajaxApply(tid);
            }
        } else {
            $.mvalidateTip("登录后才可以领取任务，请先登录");
            setTimeout(function () {
                location.href = "/account/login.html?redirectUrl=" + encodeURIComponent(location.href);
            }, 2000);
        }
    }
    $("#cancel_apply").click(function () {
        $("#alert_cancel").stop().fadeIn();
    });
    $("#alert_cancel").click(function () {
        $("#alert_cancel").stop().fadeOut();
    });
    $("#delete-bind").on("click", function () {
        var id = $(this).attr("data-id");
        $.ajax({
            type: 'POST',
            url: '/task/ajax_cancel_apply.html',//发送请求
            data: {tid: id},
            dataType: "json",
            success: function (resp) {
                if (resp.reqStatus) {
                    $.mvalidateTip(resp.msg);
                    setTimeout(function () {
                        location.reload();
                    }, 2000);
                } else {
                    $.mvalidateTip(resp.msg);
                    setTimeout(function () {
                        location.href=resp.link;
                    }, 2000);
                }
            }
        });

    });

</script>
<{include file="public/footer.html"}> 